/*

 * @(#)XlsStyle.java

 */

package com.stony.poie.ext;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;

/**
 * 
 * Style of a cell.
 * 
 * <p>
 * 
 * Last modified: February 14, 2006
 * 
 * 
 * 
 * @author Thomas Wu
 * 
 * @version 1.0.1
 * 
 */

public final class XlsStyle {

	/** Horizontal align left. */

	public final static short ALIGN_LEFT = HSSFCellStyle.ALIGN_LEFT;

	/** Horizontal align center. */

	public final static short ALIGN_CENTER = HSSFCellStyle.ALIGN_CENTER;

	/** Horizontal align right. */

	public final static short ALIGN_RIGHT = HSSFCellStyle.ALIGN_RIGHT;

	/** Vertical align top. */

	public final static short VERTICAL_TOP = HSSFCellStyle.VERTICAL_TOP;

	/** Vertical align center. */

	public final static short VERTICAL_CENTER = HSSFCellStyle.VERTICAL_CENTER;

	/** Vertical align bottom. */

	public final static short VERTICAL_BOTTOM = HSSFCellStyle.VERTICAL_BOTTOM;

	/** No border. */

	public final static short BORDER_NONE = HSSFCellStyle.BORDER_NONE;

	/** Thin border. */

	public final static short BORDER_THIN = HSSFCellStyle.BORDER_THIN;

	/** Thick border. */

	public final static short BORDER_THICK = HSSFCellStyle.BORDER_THICK;

	/** Medium border. */

	public final static short BORDER_MEDIUM = HSSFCellStyle.BORDER_MEDIUM;

	/** Double-line border. */

	public final static short BORDER_DOUBLE = HSSFCellStyle.BORDER_DOUBLE;

	/** Dash-dot border. */

	public final static short BORDER_DASH_DOT = HSSFCellStyle.BORDER_DASH_DOT;

	/* Jakarta POI library related. */

	private HSSFCellStyle hssfStyle;

	/* Horizontal alignment. */

	private short alignment;

	/* Vertical alignment. */

	private short valignment;

	/* Wheather wrap text or not. */

	private boolean wraptext;

	/* Font information. */

	private XlsFont font;

	/* Cell format. */

	private String format;

	private boolean fillBackground;

	/* Background color. */

	private short bgcolor;

	/**
	 * 
	 * Construct a new XlsStyle instance.
	 * 
	 * @param format
	 *            cell format.
	 * 
	 */

	public XlsStyle(String format) {

		this.hssfStyle = null;

		this.alignment = ALIGN_LEFT;

		this.valignment = VERTICAL_TOP;

		this.wraptext = false;

		this.font = new XlsFont();

		this.format = format;

		this.fillBackground = false;

		this.bgcolor = XlsColor.GOLD;

	}

	/**
	 * 
	 * Overloaded constructor. Construct a default XlsStyle instance.
	 * 
	 */

	public XlsStyle() {

		this(null);

	}

	/**
	 * 
	 * @return font information.
	 * 
	 */

	public XlsFont getFont() {

		return font;

	}

	/**
	 * 
	 * @param font
	 *            font information.
	 * 
	 */

	public void setFont(XlsFont font) {

		this.font = font;

	}

	/**
	 * 
	 * @return cell format.
	 * 
	 */

	public String getFormat() {

		return format;

	}

	/**
	 * 
	 * @param format
	 *            cell format.
	 * 
	 */

	public void setFormat(String format) {

		this.format = format;

	}

	/**
	 * 
	 * @return horizontal alignment.
	 * 
	 */

	public short getAlignment() {

		return alignment;

	}

	/**
	 * 
	 * @param alignment
	 *            vertical alignment.
	 * 
	 */

	public void setAlignment(short alignment) {

		this.alignment = alignment;

	}

	/**
	 * 
	 * Jakarta POI library related.
	 * 
	 * For XlsEngine to call.
	 * 
	 */

	public HSSFCellStyle getHssfStyle() {

		return hssfStyle;

	}

	/**
	 * 
	 * Jakarta POI library related.
	 * 
	 * For XlsEngine to call.
	 * 
	 */

	public void setHssfStyle(HSSFCellStyle hssfStyle) {

		this.hssfStyle = hssfStyle;

	}

	/**
	 * 
	 * @return vertical alignment.
	 * 
	 */

	public short getValignment() {

		return valignment;

	}

	/**
	 * 
	 * @param valignment
	 *            vertical alignment.
	 * 
	 */

	public void setValignment(short valignment) {

		this.valignment = valignment;

	}

	/**
	 * 
	 * @return wheather wrap text or not.
	 * 
	 */

	public boolean isWraptext() {

		return wraptext;

	}

	/**
	 * 
	 * @param wraptext
	 *            wheather wrap text or not.
	 * 
	 */

	public void setWraptext(boolean wraptext) {

		this.wraptext = wraptext;

	}

	/**
	 * 
	 * @return background color.
	 * 
	 */

	public short getBgcolor() {

		return bgcolor;

	}

	/**
	 * 
	 * @param bgcolor
	 *            background color.
	 * 
	 */

	public void setBgcolor(short bgcolor) {

		fillBackground = true;

		this.bgcolor = bgcolor;

	}

	/**
	 * 
	 * For XlsEngine to call.
	 * 
	 */

	public boolean isFillBackground() {

		return fillBackground;

	}

}
